package com.tiance.demo.service.mysql.bo.pageindex;

import java.util.Arrays;

public class RecordHead {

    public static final int SIZE = 5;

    /**
     * 普通记录
     */
    public static final int RECORD_TYPE_COMMON = 0;
    /**
     * B+树非叶子节点记录
     */
    public static final int RECORD_TYPE_NOT_LEAF = 1;
    /**
     * 最小记录
     */
    public static final int RECORD_TYPE_INFIMUM = 2;
    /**
     * 最大记录
     */
    public static final int RECORD_TYPE_SUPREMUM = 3;

    private byte[] bytes;

    /**
     * 预留位1
     */
    private int reserve1;
    /**
     * 预留位2
     */
    private int reserve2;
    /**
     * 标记该记录是否被删除
     */
    private int deleteMask;
    /**
     * B+树的每层非叶子节点中的最小记录都会添加该标记
     */
    private int minRecMask;
    /**
     * 表示当前记录拥有的记录数
     */
    private int nOwned;
    /**
     * 表示当前记录在记录堆的位置信息
     */
    private int heapNo;
    /**
     * 表示当前记录的类型，0表示普通记录，1表示B+树非叶子节点记录，2表示最小记录，3表示最大记录
     */
    private int recordType;
    /**
     * 表示下一条记录的相对位置
     */
    private int nextRecord;

    public byte[] getBytes() {
        return bytes;
    }

    public void setBytes(byte[] bytes) {
        this.bytes = bytes;
    }

    public int getReserve1() {
        return reserve1;
    }

    public void setReserve1(int reserve1) {
        this.reserve1 = reserve1;
    }

    public int getReserve2() {
        return reserve2;
    }

    public void setReserve2(int reserve2) {
        this.reserve2 = reserve2;
    }

    public int getDeleteMask() {
        return deleteMask;
    }

    public void setDeleteMask(int deleteMask) {
        this.deleteMask = deleteMask;
    }

    public int getMinRecMask() {
        return minRecMask;
    }

    public void setMinRecMask(int minRecMask) {
        this.minRecMask = minRecMask;
    }

    public int getnOwned() {
        return nOwned;
    }

    public void setnOwned(int nOwned) {
        this.nOwned = nOwned;
    }

    public int getHeapNo() {
        return heapNo;
    }

    public void setHeapNo(int heapNo) {
        this.heapNo = heapNo;
    }

    public int getRecordType() {
        return recordType;
    }

    public void setRecordType(int recordType) {
        this.recordType = recordType;
    }

    public int getNextRecord() {
        return nextRecord;
    }

    public void setNextRecord(int nextRecord) {
        this.nextRecord = nextRecord;
    }

    @Override
    public String toString() {
        return "  RecordHead:\n" +
                "  bytes=" + Arrays.toString(bytes) +
                "\n  reserve1=" + reserve1 +
                ", reserve2=" + reserve2 +
                ", deleteMask=" + deleteMask +
                ", minRecMask=" + minRecMask +
                ", nOwned=" + nOwned +
                ", heapNo=" + heapNo +
                ", recordType=" + recordType +
                ", nextRecord=" + nextRecord +
                ' ';
    }
}
